package auctionhausen



import grails.test.mixin.*

import org.junit.*

/**
 * See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
 */
@TestFor(CustomerService)
class CustomerServiceTests {
	
	void testCreateCustomer() {
		def customersCount = 0;
		Customer.metaClass.static.count = { return customersCount }
		Customer.metaClass.save = { Map m ->
			customersCount += 1
			return new Customer()
		}
		
		def params = [:]
		def customer = service.createCustomer(params)
		assert Customer.count() == 1
	}

	void testCreateCustomer_FailsForInvalidParams() {
		def customersCount = 0;
		Customer.metaClass.static.count = { return customersCount }
		Customer.metaClass.save = { Map m ->
			return null
		}
		
		def params = [:]
		def customer = service.createCustomer(params)
		assert Customer.count() == 0
	}
}


